

package com.kimo.shop.service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.kimo.shop.bean.app.dto.MyOrderDto;
import com.kimo.shop.bean.app.dto.OrderCountData;
import com.kimo.shop.bean.app.dto.ShopCartOrderMergerDto;
import com.kimo.shop.bean.model.Order;
import com.kimo.shop.bean.model.User;
import com.kimo.shop.bean.param.*;

import cn.hutool.core.date.DateTime;
import com.kimo.shop.bean.vo.UnDeliveryOrderExcelVO;
import org.apache.ibatis.annotations.Param;
import com.kimo.shop.common.util.PageParam;

/**
 * @author kimo-taozhouchuan on 2018/09/15.
 */
public interface OrderService extends IService<Order> {


    Order getOrderByOrderNumber(String orderNumber);

    void getOrderItenRefundStatus(Order order);

    IPage<MyOrderDto> orderListByStatus(PageParam<MyOrderDto> page, Integer status, Long stationId);

    Boolean orderStationByOrderNumber(List<String> orderNumberList, String userId, Long stationId);
    /**
     * 根据订单号和用户id获取订单
     *
     * @param orderNumber
     * @param userId
     * @return
     */
    Order getOrderByOrderNumberAndUserId(String orderNumber, String userId, boolean valid);

    /**
     * 根据店铺id和订单号获取订单
     *
     * @param orderNumber
     * @param shopId
     * @return
     */
    Order getOrderByOrderNumberAndShopId(String orderNumber, Long shopId, boolean valid);

    /**
     * 根据店铺id获取支付数据
     * @param shopId
     */
    OrderPayParam getPayUserCountByshopId(Long shopId, Date startTime, Date endTime);

    /**
     * 根据时间和店铺id获取分段时间数据
     */
    OrderPayParam getActualTotalByHour(Long shopId, Date startTime, Date endTime);

    /**
     * 根据天数和店铺id获取分段时间数据
     */
    List<OrderPayParam> getActualTotalByDay(Long shopId, Date startTime, Date endTime);


    ShopCartOrderMergerDto putConfirmOrderCache(String userId, ShopCartOrderMergerDto shopCartOrderMergerDto);

    ShopCartOrderMergerDto getConfirmOrderCache(String userId);

    void removeConfirmOrderCache(String userId);

    List<Order> submit(String userId, ShopCartOrderMergerDto mergerOrder);

    void delivery(Order order);

    List<Order> listUnRefundOrderAndOrderItems(Integer orderStatus, DateTime lessThanUpdateTime);

    void cancelOrders(List<Order> orders);

    void receiptOrder(List<Order> orders);

    List<Order> listOrdersDetialByOrder(Order order, Date startTime, Date endTime);

    IPage<Order> pageOrdersDetialByOrderParam(Page<Order> page, OrderParam orderParam);

    void deleteOrders(List<Order> orders);

    OrderCountData getOrderCount(String userId);

    void changeAmount(Order order);

    Order getOrderDetailByOrderNumberAndShopId(String orderNumber, Long shopId, Integer dbLang);

    List<Order> getOrderPayInfoByOrderNumber(List<String> orderNumberList);

    Map<Long, Integer> getOrderItemMap(Long orderId);

    Order getOrderAndOrderItemByOrderNumber(String orderNumber);
    /**
     * 根据订单号获取订单及订单项
     *
     * @param orderNumber
     * @return
     */
    List<Order> getOrderAndOrderItemByOrderNumberList(@Param("orderNumberList") Set<String> orderNumber);

    CustomerRespParam countPayNum(CustomerReqParam param);

    List<CustomerPayParam> countCustomerParam(CustomerReqParam param);

    Integer countMemberPayNum(CustomerReqParam param);

    CustomerDealRespParam getCustomerDeal(CustomerReqParam param);

    List<CustomerRFMRespParam> countPayNumRFM(CustomerRFMReqParam param);

    CustomerConsumeRespParam getConsumePower(CustomerConsumeReqParam param);

    CustomerConsumeRespParam getConsumeFrequency(CustomerConsumeReqParam param);

    CustomerRepurchaseRespParam getConsumeRepurchaseCount(CustomerConsumeReqParam param);

    MemberContributeRespParam getMemberContributeValue(MemberReqParam param);

    MemberDealRespParam getMemberDeal(MemberReqParam param);

    List<CustomerRFMRespTableParam> countPayNumRFM2(CustomerRFMReqParam param);

    UserManagerParam getConsumeData(UserManagerParam param);

    IPage<Order> pageByUserId(PageParam<Order> page, String userId);

    /**
     * 获取订单的创建状态，给秒杀提供查询是否已经创建订单成功的功能
     * @param orderNumber 订单id
     * @return
     */
    Integer countByOrderNumber(String orderNumber);


    /**
     * 获取用户的成交留存率, 统计用户第一次成交后，之后的1到6个月的留存用户数
     * @param param 条件查询参数
     * @return 成交留存信息列表
     */
    List<CustomerRetainRespParam> getTradeRetained(CustomerRetainedReqParam param);

    /**
     * 清除成交留存率换成
     * @param param 参数
     */
    void removeCacheTradeRetained(CustomerRetainedReqParam param);

    /**
     * 根据订单号和商家id获取信息
     * @param orderNumber 订单编号
     * @param shopId 店铺id
     * @return 信息
     */
    UnDeliveryOrderExcelVO getOrderAndOrderItemsByOrderNumberAndShopId(String orderNumber, Long shopId);

    /**
     * 查询店铺订单各状态数量
     * @param shopId
     * @return
     */
    OrderCountData getOrderCountOfStatusByShopId(Long shopId);

    /**
     * 获取在指定时间范围内消费了指定金额的用户
     * @param minAmount
     * @param maxAmount
     * @param startDate
     * @param endTime
     * @return
     */
    List<User> listUserByConsAmount(BigDecimal minAmount, BigDecimal maxAmount, Date startDate, Date endTime);
}
